/**
 * Created by Administrator on 2017/5/25.
 */
"use strict";
//引入模块
const mongoose = require('mongoose');
const db = require('./db');

// Schema 结构
var AdminSchema = new mongoose.Schema({
    aid        :{type:Number,index:true},
    username   :{type:String,index: true},//管理员名字
    password   :{type:String,index: true},//管理员密码
    staute     :{type : String,default:"A"},//级别
    headimg    :{type : String,default:"/up/images/head/head.png"},//头像
    sex        :{type : String,default:"男"},//性别
    age        :{type : Number,default:23},//年龄
    email      :{type : String,default:"105@qq.com"},//邮箱
    nickname   :{type : String,default:""},//昵称
    truename   :{type : String,default:""}//真名
});

AdminSchema.statics.findFn = function(obj,obj1, callback) {
    return this.model('Admin').find(obj, callback).sort(obj1);
};
AdminSchema.statics.findFnLimit = function(obj,obj1,num1,callback) {
    return this.model('Admin').find(obj).sort(obj1).limit(num1).exec(callback);
};
AdminSchema.statics.findSortOne = function(obj,obj1,callback) {
    return this.model('Admin').findOne(obj).sort(obj1).exec(callback);
};
AdminSchema.statics.findConut = function(obj,callback) {
    return this.model('Admin').find(obj).count().exec(callback);
};
AdminSchema.statics.updateFn = function(obj,obj1,callback) {
    return this.model('Admin').update(obj,obj1).exec(callback);
};

var AdminModel = db.model('Admin', AdminSchema);
module.exports=AdminModel;